/**
 * @author syt123450 / https://github.com/syt123450
 * @author Botime / https://github.com/BoTime
 */

/**
 * This is a singleton object.
 * This object contains all country information in detail.
 */

var CountryData = ( function () {

    var basicCountryData = {

        AD: { colorCode: 186, name: 'ANDORRA', lat: 42.5, lon: 1.6 },
        AE: { colorCode: 22, name: 'UNITED ARAB EMIRATES', lat: 24, lon: 54 },
        AF: { colorCode: 30, name: 'AFGHANISTAN', lat: 33, lon: 65 },
        AG: { colorCode: 190, name: 'ANTIGUA AND BARBUDA', lat: 17.05, lon: -61.8 },
        AI: { colorCode: 215, name: 'ANGUILLA', lat: 18.25, lon: -63.1667 },
        AL: { colorCode: 69, name: 'ALBANIA', lat: 41, lon: 20 },
        AM: { colorCode: 115, name: 'ARMENIA', lat: 40, lon: 45 },
        AO: { colorCode: 47, name: 'ANGOLA', lat: -12.5, lon: 18.5 },
        AQ: { colorCode: 152, name: 'ANTARCTICA', lat: -90, lon: 0 },
        AR: { colorCode: 76, name: 'ARGENTINA', lat: -34, lon: -64 },
        AS: { colorCode: 208, name: 'AMERICAN SAMOA', lat: -14.3333, lon: -170 },
        AT: { colorCode: 35, name: 'AUSTRIA', lat: 47.3333, lon: 13.3333 },
        AU: { colorCode: 51, name: 'AUSTRALIA', lat: -27, lon: 133 },
        AW: { colorCode: 210, name: 'ARUBA', lat: 12.5, lon: -69.9667 },
        AZ: { colorCode: 106, name: 'AZERBAIJAN', lat: 40.5, lon: 47.5 },
        BA: { colorCode: 94, name: 'BOSNIA AND HERZEGOVINA', lat: 44, lon: 18 },
        BB: { colorCode: 191, name: 'BARBADOS', lat: 13.1667, lon: -59.5333 },
        BD: { colorCode: 31, name: 'BANGLADESH', lat: 24, lon: 90 },
        BE: { colorCode: 100, name: 'BELGIUM', lat: 50.8333, lon: 4 },
        BF: { colorCode: 2, name: 'BURKINA FASO', lat: 13, lon: -2 },
        BG: { colorCode: 103, name: 'BULGARIA', lat: 43, lon: 25 },
        BH: { colorCode: 185, name: 'BAHRAIN', lat: 26, lon: 50.55 },
        BI: { colorCode: 104, name: 'BURUNDI', lat: -3.5, lon: 30 },
        BJ: { colorCode: 143, name: 'BENIN', lat: 9.5, lon: 2.25 },
        BL: { colorCode: 203, name: 'SAINT BARTHÉLEMY' },
        BM: { colorCode: 219, name: 'BERMUDA', lat: 32.3333, lon: -64.75 },
        BN: { colorCode: 170, name: 'BRUNEI DARUSSALAM', lat: 4.5, lon: 114.6667 },
        BO: { colorCode: 10, name: 'BOLIVIA, PLURINATIONAL STATE OF', lat: -17, lon: -65 },
        BR: { colorCode: 24, name: 'BRAZIL', lat: -10, lon: -55 },
        BS: { colorCode: 161, name: 'BAHAMAS', lat: 24.25, lon: -76 },
        BT: { colorCode: 156, name: 'BHUTAN', lat: 27.5, lon: 90.5 },
        BW: { colorCode: 16, name: 'BOTSWANA', lat: -22, lon: 24 },
        BY: { colorCode: 5, name: 'BELARUS', lat: 53, lon: 28 },
        BZ: { colorCode: 23, name: 'BELIZE', lat: 17.25, lon: -88.75 },
        CA: { colorCode: 97, name: 'CANADA', lat: 60, lon: -95 },
        CD: { colorCode: 27, name: 'CONGO, THE DEMOCRATIC REPUBLIC OF THE', lat: 0, lon: 25 },
        CF: { colorCode: 132, name: 'CENTRAL AFRICAN REPUBLIC', lat: 7, lon: 21 },
        CG: { colorCode: 110, name: 'CONGO', lat: -1, lon: 15 },
        CH: { colorCode: 13, name: 'SWITZERLAND', lat: 47, lon: 8 },
        CI: { colorCode: 11, name: 'CÔTE D\'IVOIRE', lat: 8, lon: -5 },
        CK: { colorCode: 206, name: 'COOK ISLANDS', lat: -21.2333, lon: -159.7667 },
        CL: { colorCode: 128, name: 'CHILE', lat: -30, lon: -71 },
        CM: { colorCode: 14, name: 'CAMEROON', lat: 6, lon: 12 },
        CN: { colorCode: 96, name: 'CHINA', lat: 35, lon: 105 },
        CO: { colorCode: 45, name: 'COLOMBIA', lat: 4, lon: -72 },
        CR: { colorCode: 78, name: 'COSTA RICA', lat: 10, lon: -84 },
        CU: { colorCode: 42, name: 'CUBA', lat: 21.5, lon: -80 },
        CV: { colorCode: 172, name: 'CAPE VERDE', lat: 16, lon: -24 },
        CY: { colorCode: 167, name: 'CYPRUS', lat: 35, lon: 33 },
        CZ: { colorCode: 67, name: 'CZECH REPUBLIC', lat: 49.75, lon: 15.5 },
        DE: { colorCode: 48, name: 'GERMANY', lat: 51, lon: 9 },
        DJ: { colorCode: 105, name: 'DJIBOUTI', lat: 11.5, lon: 43 },
        DK: { colorCode: 57, name: 'DENMARK', lat: 56, lon: 10 },
        DM: { colorCode: 181, name: 'DOMINICA', lat: 15.4167, lon: -61.3333 },
        DO: { colorCode: 32, name: 'DOMINICAN REPUBLIC', lat: 19, lon: -70.6667 },
        DZ: { colorCode: 12, name: 'ALGERIA', lat: 28, lon: 3 },
        EC: { colorCode: 142, name: 'ECUADOR', lat: -2, lon: -77.5 },
        EE: { colorCode: 113, name: 'ESTONIA', lat: 59, lon: 26 },
        EG: { colorCode: 87, name: 'EGYPT', lat: 27, lon: 30 },
        EH: { colorCode: 66, name: 'WESTERN SAHARA', lat: 24.5, lon: -13 },
        ER: { colorCode: 149, name: 'ERITREA', lat: 15, lon: 39 },
        ES: { colorCode: 118, name: 'SPAIN', lat: 40, lon: -4 },
        ET: { colorCode: 63, name: 'ETHIOPIA', lat: 8, lon: 38 },
        FI: { colorCode: 70, name: 'FINLAND', lat: 64, lon: 26 },
        FJ: { colorCode: 158, name: 'FIJI', lat: -18, lon: 175 },
        FK: { colorCode: 163, name: 'FALKLAND ISLANDS (MALVINAS)', lat: -51.75, lon: -59 },
        FM: { colorCode: 184, name: 'MICRONESIA, FEDERATED STATES OF', lat: 6.9167, lon: 158.25 },
        FO: { colorCode: 178, name: 'FAROE ISLANDS', lat: 62, lon: -7 },
        FR: { colorCode: 3, name: 'FRANCE', lat: 46, lon: 2 },
        GA: { colorCode: 119, name: 'GABON', lat: -1, lon: 11.75 },
        GB: { colorCode: 77, name: 'UNITED KINGDOM', lat: 54, lon: -2 },
        GD: { colorCode: 197, name: 'GRENADA', lat: 12.1167, lon: -61.6667 },
        GE: { colorCode: 89, name: 'GEORGIA', lat: 42, lon: 43.5 },
        GG: { colorCode: 217, name: 'GUERNSEY', lat: 49.5, lon: -2.56 },
        GH: { colorCode: 34, name: 'GHANA', lat: 8, lon: -2 },
        GI: { colorCode: 222, name: 'GIBRALTAR', lat: 36.1833, lon: -5.3667 },
        GL: { colorCode: 55, name: 'GREENLAND', lat: 72, lon: -40 },
        GM: { colorCode: 164, name: 'GAMBIA', lat: 13.4667, lon: -16.5667 },
        GN: { colorCode: 80, name: 'GUINEA', lat: 11, lon: -10 },
		GP: { colorCode: 3, name: 'FRANCE', lat: 46, lon: 2 },
        GQ: { colorCode: 101, name: 'EQUATORIAL GUINEA', lat: 2, lon: 10 },
        GR: { colorCode: 140, name: 'GREECE', lat: 39, lon: 22 },
        GT: { colorCode: 64, name: 'GUATEMALA', lat: 15.5, lon: -90.25 },
        GU: { colorCode: 227, name: 'GUAM', lat: 13.4667, lon: 144.7833 },
        GW: { colorCode: 33, name: 'GUINEA-BISSAU', lat: 12, lon: -15 },
        GY: { colorCode: 99, name: 'GUYANA', lat: 5, lon: -59 },
        HK: { colorCode: 96, name: 'CHINA', lat: 35, lon: 105 },
        HN: { colorCode: 125, name: 'HONDURAS', lat: 15, lon: -86.5 },
        HR: { colorCode: 54, name: 'CROATIA', lat: 45.1667, lon: 15.5 },
        HT: { colorCode: 93, name: 'HAITI', lat: 19, lon: -72.4167 },
        HU: { colorCode: 120, name: 'HUNGARY', lat: 47, lon: 20 },
        ID: { colorCode: 7, name: 'INDONESIA', lat: -5, lon: 120 },
        IE: { colorCode: 81, name: 'IRELAND', lat: 53, lon: -8 },
        IL: { colorCode: 137, name: 'ISRAEL', lat: 31.5, lon: 34.75 },
        IM: { colorCode: 226, name: 'ISLE OF MAN', lat: 54.23, lon: -4.55 },
        IN: { colorCode: 95, name: 'INDIA', lat: 20, lon: 77 },
        IQ: { colorCode: 53, name: 'IRAQ', lat: 33, lon: 44 },
        IR: { colorCode: 61, name: 'IRAN, ISLAMIC REPUBLIC OF', lat: 32, lon: 53 },
        IS: { colorCode: 126, name: 'ICELAND', lat: 65, lon: -18 },
        IT: { colorCode: 28, name: 'ITALY', lat: 42.8333, lon: 12.8333 },
        JE: { colorCode: 214, name: 'JERSEY', lat: 49.21, lon: -2.13 },
        JM: { colorCode: 166, name: 'JAMAICA', lat: 18.25, lon: -77.5 },
        JO: { colorCode: 20, name: 'JORDAN', lat: 31, lon: 36 },
        JP: { colorCode: 40, name: 'JAPAN', lat: 36, lon: 138 },
        KE: { colorCode: 18, name: 'KENYA', lat: 1, lon: 38 },
        KG: { colorCode: 72, name: 'KYRGYZSTAN', lat: 41, lon: 75 },
        KH: { colorCode: 123, name: 'CAMBODIA', lat: 13, lon: 105 },
        KI: { colorCode: 183, name: 'KIRIBATI', lat: 1.4167, lon: 173 },
        KM: { colorCode: 176, name: 'COMOROS', lat: -12.1667, lon: 44.25 },
        KN: { colorCode: 201, name: 'SAINT KITTS AND NEVIS', lat: 17.3333, lon: -62.75 },
        KP: { colorCode: 139, name: 'KOREA, DEMOCRATIC PEOPLE\'S REPUBLIC OF', lat: 40, lon: 127 },
        KR: { colorCode: 124, name: 'KOREA, REPUBLIC OF', lat: 37, lon: 127.5 },
        KW: { colorCode: 159, name: 'KUWAIT', lat: 29.3375, lon: 47.6581 },
        KY: { colorCode: 200, name: 'CAYMAN ISLANDS', lat: 19.5, lon: -80.5 },
        KZ: { colorCode: 151, name: 'KAZAKHSTAN', lat: 48, lon: 68 },
        LA: { colorCode: 138, name: 'LAO PEOPLE\'S DEMOCRATIC REPUBLIC', lat: 18, lon: 105 },
        LB: { colorCode: 147, name: 'LEBANON', lat: 33.8333, lon: 35.8333 },
        LC: { colorCode: 194, name: 'SAINT LUCIA', lat: 13.8833, lon: -61.1333 },
        LI: { colorCode: 211, name: 'LIECHTENSTEIN', lat: 47.1667, lon: 9.5333 },
        LK: { colorCode: 136, name: 'SRI LANKA', lat: 7, lon: 81 },
        LR: { colorCode: 130, name: 'LIBERIA', lat: 6.5, lon: -9.5 },
        LS: { colorCode: 102, name: 'LESOTHO', lat: -29.5, lon: 28.5 },
        LT: { colorCode: 134, name: 'LITHUANIA', lat: 56, lon: 24 },
        LU: { colorCode: 175, name: 'LUXEMBOURG', lat: 49.75, lon: 6.1667 },
        LV: { colorCode: 58, name: 'LATVIA', lat: 57, lon: 25 },
        LY: { colorCode: 4, name: 'LIBYA', lat: 25, lon: 17 },
        MA: { colorCode: 129, name: 'MOROCCO', lat: 32, lon: -5 },
        MC: { colorCode: 224, name: 'MONACO', lat: 43.7333, lon: 7.4 },
        MD: { colorCode: 146, name: 'MOLDOVA, REPUBLIC OF', lat: 47, lon: 29 },
        ME: { colorCode: 112, name: 'MONTENEGRO', lat: 42, lon: 19 },
        MG: { colorCode: 9, name: 'MADAGASCAR', lat: -20, lon: 47 },
        MH: { colorCode: 209, name: 'MARSHALL ISLANDS', lat: 9, lon: 168 },
        MK: { colorCode: 15, name: 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', lat: 41.8333, lon: 22 },
        ML: { colorCode: 26, name: 'MALI', lat: 17, lon: -4 },
        MM: { colorCode: 62, name: 'MYANMAR', lat: 22, lon: 98 },
        MN: { colorCode: 155, name: 'MONGOLIA', lat: 46, lon: 105 },
        MP: { colorCode: 187, name: 'NORTHERN MARIANA ISLANDS', lat: 15.2, lon: 145.75 },
        MR: { colorCode: 46, name: 'MAURITANIA', lat: 20, lon: -12 },
        MS: { colorCode: 202, name: 'MONTSERRAT', lat: 16.75, lon: -62.2 },
        MT: { colorCode: 198, name: 'MALTA', lat: 35.8333, lon: 14.5833 },
        MU: { colorCode: 177, name: 'MAURITIUS', lat: -20.2833, lon: 57.55 },
        MV: { colorCode: 199, name: 'MALDIVES', lat: 3.25, lon: 73 },
        MW: { colorCode: 121, name: 'MALAWI', lat: -13.5, lon: 34 },
        MX: { colorCode: 21, name: 'MEXICO', lat: 23, lon: -102 },
        MY: { colorCode: 107, name: 'MALAYSIA', lat: 2.5, lon: 112.5 },
        MZ: { colorCode: 39, name: 'MOZAMBIQUE', lat: -18.25, lon: 35 },
        NA: { colorCode: 85, name: 'NAMIBIA', lat: -22, lon: 17 },
        NC: { colorCode: 157, name: 'NEW CALEDONIA', lat: -21.5, lon: 165.5 },
        NE: { colorCode: 56, name: 'NIGER', lat: 16, lon: 8 },
        NG: { colorCode: 82, name: 'NIGERIA', lat: 10, lon: 8 },
        NI: { colorCode: 127, name: 'NICARAGUA', lat: 13, lon: -85 },
        NL: { colorCode: 131, name: 'NETHERLANDS', lat: 52.5, lon: 5.75 },
        NO: { colorCode: 145, name: 'NORWAY', lat: 62, lon: 10 },
        NP: { colorCode: 148, name: 'NEPAL', lat: 28, lon: 84 },
        NR: { colorCode: 221, name: 'NAURU', lat: -0.5333, lon: 166.9167 },
        NU: { colorCode: 204, name: 'NIUE', lat: -19.0333, lon: -169.8667 },
        NZ: { colorCode: 41, name: 'NEW ZEALAND', lat: -41, lon: 174 },
        OM: { colorCode: 74, name: 'OMAN', lat: 21, lon: 57 },
        PA: { colorCode: 75, name: 'PANAMA', lat: 9, lon: -80 },
        PE: { colorCode: 1, name: 'PERU', lat: -10, lon: -76 },
        PF: { colorCode: 173, name: 'FRENCH POLYNESIA', lat: -15, lon: -140 },
        PG: { colorCode: 52, name: 'PAPUA NEW GUINEA', lat: -6, lon: 147 },
        PH: { colorCode: 108, name: 'PHILIPPINES', lat: 13, lon: 122 },
        PK: { colorCode: 6, name: 'PAKISTAN', lat: 30, lon: 70 },
        PL: { colorCode: 84, name: 'POLAND', lat: 52, lon: 20 },
        PM: { colorCode: 205, name: 'SAINT PIERRE AND MIQUELON', lat: 46.8333, lon: -56.3333 },
        PN: { colorCode: 223, name: 'PITCAIRN', lat: -24.7, lon: -127.4 },
        PR: { colorCode: 168, name: 'PUERTO RICO', lat: 18.25, lon: -66.5 },
        PS: { colorCode: 169, name: 'PALESTINIAN TERRITORY, OCCUPIED', lat: 32, lon: 35.25 },
        PT: { colorCode: 44, name: 'PORTUGAL', lat: 39.5, lon: -8 },
        PW: { colorCode: 188, name: 'PALAU', lat: 7.5, lon: 134.5 },
        PY: { colorCode: 79, name: 'PARAGUAY', lat: -23, lon: -58 },
        QA: { colorCode: 165, name: 'QATAR', lat: 25.5, lon: 51.25 },
		RE: { colorCode: 3, name: 'FRANCE', lat: 46, lon: 2 },
        RO: { colorCode: 59, name: 'ROMANIA', lat: 46, lon: 25 },
        RS: { colorCode: 111, name: 'SERBIA', lat: 44, lon: 21 },
        RU: { colorCode: 92, name: 'RUSSIAN FEDERATION', lat: 60, lon: 100 },
        RW: { colorCode: 114, name: 'RWANDA', lat: -2, lon: 30 },
        SA: { colorCode: 90, name: 'SAUDI ARABIA', lat: 25, lon: 45 },
        SB: { colorCode: 73, name: 'SOLOMON ISLANDS', lat: -8, lon: 159 },
        SC: { colorCode: 189, name: 'SEYCHELLES', lat: -4.5833, lon: 55.6667 },
        SD: { colorCode: 49, name: 'SUDAN', lat: 15, lon: 30 },
        SE: { colorCode: 36, name: 'SWEDEN', lat: 62, lon: 15 },
        SG: { colorCode: 228, name: 'SINGAPORE', lat: 1.3667, lon: 103.8 },
        SH: { colorCode: 213, name: 'SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA', lat: -15.9333, lon: -5.7 },
        SI: { colorCode: 144, name: 'SLOVENIA', lat: 46, lon: 15 },
        SK: { colorCode: 133, name: 'SLOVAKIA', lat: 48.6667, lon: 19.5 },
        SL: { colorCode: 25, name: 'SIERRA LEONE', lat: 8.5, lon: -11.5 },
        SM: { colorCode: 218, name: 'SAN MARINO', lat: 43.7667, lon: 12.4167 },
        SN: { colorCode: 116, name: 'SENEGAL', lat: 14, lon: -14 },
        SO: { colorCode: 29, name: 'SOMALIA', lat: 10, lon: 49 },
        SR: { colorCode: 65, name: 'SURINAME', lat: 4, lon: -56 },
        ST: { colorCode: 179, name: 'SAO TOME AND PRINCIPE', lat: 1, lon: 7 },
        SV: { colorCode: 98, name: 'EL SALVADOR', lat: 13.8333, lon: -88.9167 },
        SY: { colorCode: 71, name: 'SYRIAN ARAB REPUBLIC', lat: 35, lon: 38 },
        SZ: { colorCode: 153, name: 'SWAZILAND', lat: -26.5, lon: 31.5 },
        TC: { colorCode: 192, name: 'TURKS AND CAICOS ISLANDS', lat: 21.75, lon: -71.5833 },
        TD: { colorCode: 68, name: 'CHAD', lat: 15, lon: 19 },
        TG: { colorCode: 117, name: 'TOGO', lat: 8, lon: 1.1667 },
        TH: { colorCode: 50, name: 'THAILAND', lat: 15, lon: 100 },
        TJ: { colorCode: 122, name: 'TAJIKISTAN', lat: 39, lon: 71 },
        TL: { colorCode: 160, name: 'TIMOR-LESTE', lat: -8.55, lon: 125.5167 },
        TM: { colorCode: 141, name: 'TURKMENISTAN', lat: 40, lon: 60 },
        TN: { colorCode: 83, name: 'TUNISIA', lat: 34, lon: 9 },
        TO: { colorCode: 182, name: 'TONGA', lat: -20, lon: -175 },
        TR: { colorCode: 37, name: 'TURKEY', lat: 39, lon: 35 },
        TT: { colorCode: 171, name: 'TRINIDAD AND TOBAGO', lat: 11, lon: -61 },
        TV: { colorCode: 220, name: 'TUVALU', lat: -8, lon: 178 },
        TW: { colorCode: 19, name: 'TAIWAN', lat: 23.5, lon: 121 },
        TZ: { colorCode: 88, name: 'TANZANIA, UNITED REPUBLIC OF', lat: -6, lon: 35 },
        UA: { colorCode: 17, name: 'UKRAINE', lat: 49, lon: 32 },
        UG: { colorCode: 38, name: 'UGANDA', lat: 1, lon: 32 },
        US: { colorCode: 150, name: 'UNITED STATES', lat: 38, lon: -97 },
        UY: { colorCode: 109, name: 'URUGUAY', lat: -33, lon: -56 },
        UZ: { colorCode: 154, name: 'UZBEKISTAN', lat: 41, lon: 64 },
        VA: { colorCode: 225, name: 'HOLY SEE (VATICAN CITY STATE)', lat: 41.9, lon: 12.45 },
        VC: { colorCode: 193, name: 'SAINT VINCENT AND THE GRENADINES', lat: 13.25, lon: -61.2 },
        VE: { colorCode: 43, name: 'VENEZUELA, BOLIVARIAN REPUBLIC OF', lat: 8, lon: -66 },
        VG: { colorCode: 212, name: 'VIRGIN ISLANDS, BRITISH', lat: 18.5, lon: -64.5 },
        VI: { colorCode: 196, name: 'VIRGIN ISLANDS, U.S.', lat: 18.3333, lon: -64.8333 },
        VN: { colorCode: 91, name: 'VIET NAM', lat: 16, lon: 106 },
        VU: { colorCode: 162, name: 'VANUATU', lat: -16, lon: 167 },
        WF: { colorCode: 207, name: 'WALLIS AND FUTUNA', lat: -13.3, lon: -176.2 },
        WS: { colorCode: 174, name: 'SAMOA', lat: -13.5833, lon: -172.3333 },
        YE: { colorCode: 8, name: 'YEMEN', lat: 15, lon: 48 },
        YT: { colorCode: 195, name: 'MAYOTTE', lat: -12.8333, lon: 45.1667 },
        ZA: { colorCode: 86, name: 'SOUTH AFRICA', lat: -29, lon: 24 },
        ZM: { colorCode: 60, name: 'ZAMBIA', lat: -15, lon: 30 },
        ZW: { colorCode: 135, name: 'ZIMBABWE', lat: -20, lon: 30 }

    };

    // This function create the center ( Three.js vector3 ) of all country, and add the center to "basicCountryData" object

    function createCountryCenter () {

        var rad = 100;

        for ( var s in basicCountryData ) {

            var country = basicCountryData[ s ];

            var lon = country.lon - 90;
            var lat = country.lat;

            var phi = Math.PI / 2 - lat * Math.PI / 180 - Math.PI * 0.01;
            var theta = 2 * Math.PI - lon * Math.PI / 180 + Math.PI * 0.06;

            var center = new THREE.Vector3();
            center.x = Math.sin( phi ) * Math.cos( theta ) * rad;
            center.y = Math.cos( phi ) * rad;
            center.z = Math.sin( phi ) * Math.sin( theta ) * rad;

            country.center = center;

        }

    }

    // when CountryData is initialized, it will automatically create the center ( Three.js vector3) for all country

    createCountryCenter();

    return basicCountryData;

}() );

export { CountryData }